// Creation-Date: 2021-07-27 15:00:46
// Author: zinface
// Description: This file gets System information
#ifndef __SYSTEM__H__
#define __SYSTEM__H__

#include "linuxos.h"

// #include "etc/os-release.h"
#include "proc/cmdline.h"


#define CPU_LOAD_KEY "average:"

typedef struct _System {
    // cmdline
    CmdLine cmdline;
    
    // /etc/os-release
    char Firmware_Version[100];     // /etc/os-release
    
    // kernel
    char Kernel_Version[100];       // uname
    char Architecture[100];         // arch
    
    // uptime
    char Runtime[100];
    // date
    char Systime[100];
    
    // stat
    char Load[100];
} System;

#define SYSTEM_ARCH_CMD             "arch"
#define SYSTEM_UNAME_CMD            "uname"
#define SYSTEM_UNAME_MACHINE_CMD    "uname -m"
#define SYSTEM_KERNEL_VERSION_CMD   "uname -r"
#define SYSTEM_FIRMWARE_VERSION_CMD "cat e/etc/os-releas | grep \"^VERSION=\""

#define SYSTEM_UPTIME_CMD           "uptime"

#define SYSTEM_DATE_CMD             "date"
#define SYSTEM_DATE_TIME_CMD        "date  +\%F\\ \%X"

bool proc_systeminfo_of_buffer(char *buf, System *s);

bool initSystem(System *s);

// usage: 
// ┌──────────────────────────────────────────────────────────────────────────────┐
// │ System info = {0};                                                           │
// │ initSystem(&info);                                                           │
// └──────────────────────────────────────────────────────────────────────────────┘

#endif  //!__SYSTEM__H__